#include "types/common.h"

#ifndef _buffer_info_h_
#define _buffer_info_h_

struct BufferInfo
{
	~BufferInfo()
	{
		if(tablename != NULL)
		{
			delete [] tablename;
		}
	}
	BufferInfo() : tablename(NULL),isdirty(false),isfree(true),prev(NULL),next(NULL)
	{
	}
	
	char* tablename;
	UINT32 block_num;
	bool isdirty;
	bool isfree;
	BYTE *buffer;

	BufferInfo *prev;
	BufferInfo *next;
};

struct BufferKey
{
	BufferKey(string t, UINT32 b):tablename(t),block_num(b)
	{
	}
	string tablename;
	UINT32 block_num;
};

class BufferTraits
{
public:
	bool isequal(BufferKey k1, BufferKey k2)
	{
		return (k1.tablename == k2.tablename) && (k1.block_num == k2.block_num);
	}
	UINT32 gethash(BufferKey k)
	{
		return 0;
	}
};

typedef HashMap<BufferKey, BufferInfo *, BufferTraits> BufferIndex;

#endif
